package com.zcf.handler;

import com.zcf.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zcf
 */
@RestControllerAdvice
@Slf4j
public class GlobalHandlerException {
    @ExceptionHandler
    public Result result(Exception exception){
      log.info("异常信息:{}",exception.getMessage());
    return Result.error(StringUtils.hasLength(exception.getMessage())? exception.getMessage() : "服务器异常");
    }
}
